const db = require('../db')
//引入uuid模块
const crypto = require('crypto');

//抽离订单业务方法

//下单
exports.shoping = (query) => {
    console.log(query)
    const sql = 'insert into wx_order set ? ';
    const order_id = crypto.randomUUID()
    //返回promise 让对应的路由使用
    return new Promise((resolve, reject) => {
        db.query(sql, {
            ...query,
            order_id,

        }, (err, results) => {
            if (err) {
                reject(err);
            } else {
                resolve(results);
            }
        });
    });
};
